﻿<UserControl xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"  x:Class="LiveTiss.Telas.MenuScreen"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:guias="clr-namespace:LiveTiss.Guias"  
    xmlns:uc="clr-namespace:LiveTiss.Guias.UserControls"  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:popup="clr-namespace:SL4PopupMenu;assembly=SL4PopupMenu"
    xmlns:converter="clr-namespace:LiveTiss.Classes.TypeConverter"
    mc:Ignorable="d" x:Name="root">

    <UserControl.Resources>
        <converter:MenuTipoGuiaConverter x:Key="TipoGuiaMenuConverter" />
        <converter:TreeViewNodeMenuConverter x:Key="treeViewNodeMenuConverter" />
        <sdk:HierarchicalDataTemplate x:Key="ItemTemplateTreeView" >
            <StackPanel>
                <TextBlock Text="{Binding Nome}"/>
            </StackPanel>
        </sdk:HierarchicalDataTemplate>
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="72"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="140" MinWidth="200"/>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid x:Name="Fundo" Margin="0" Grid.Row="1" Grid.Column="1">
            <Image x:Name="BackGroundGeral" Source="/LiveTiss;component/Content/BackGroundGeral.png" Stretch="Fill" Margin="0"/>
            <Image x:Name="MarcaDagua" Source="/LiveTiss;component/Content/Aplicacao_background.png" Stretch="Fill" VerticalAlignment="Center" Margin="0" Height="223" Width="527" HorizontalAlignment="Center"/>
        </Grid>
        <ScrollViewer x:Name="Meio" Grid.Column="1" Margin="0" Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">

            <Grid x:Name="grdGuia" Width="960" Margin="0,5,0,5" Visibility="Collapsed">
                <Rectangle Stroke="#4D898989" Fill="#B2FFFFFF" />
                <ScrollViewer x:Name="svwGuia" Margin="10,60,10,20" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" BorderBrush="{x:Null}">
                    
                </ScrollViewer>
                <Button x:Name="btnGuiaFechar" Content="X" HorizontalAlignment="Right" Margin="0,8,8,0" Width="34" Style="{StaticResource Fechar_TipoGuia}" Foreground="White" VerticalAlignment="Top" Height="30" Click="btnGuiaFechar_Click"/>
                <Button x:Name="btnGuiaSalvar" Content="X" HorizontalAlignment="Right" Margin="0,8,51,0" Width="34" Style="{StaticResource Salvar_TipoGuia}" Foreground="White" VerticalAlignment="Top" Height="30" Click="btnGuiaSalvar_Click"/>
            </Grid>
            
        </ScrollViewer>
        <Grid x:Name="Lateral" Margin="0" Grid.Row="2">
            <Rectangle x:Name="Retangulo_Efeito" Fill="#FFD04242">
                <Rectangle.Effect>
                    <DropShadowEffect BlurRadius="30" Opacity="0.25"/>
                </Rectangle.Effect>
            </Rectangle>
            <!--
            ItemTemplate="{StaticResource ItemTemplateTreeView}"-->
            <toolkit:BusyIndicator Margin="0,22,0,0" x:Name="bsyTreeView">
                <sdk:TreeView Name="tvwAcompanhaGuia" Style="{StaticResource TreeViewStyle}"  ItemContainerStyle="{StaticResource ConnectingLinesTreeViewItem}"
                          ItemsSource="{Binding treeViewDataList,ElementName=root}" >
                    <sdk:TreeView.ItemTemplate>
                        <!--TreeViewRoot Template-->
                        <sdk:HierarchicalDataTemplate ItemsSource="{Binding ListaTipoGuias}">
                            <StackPanel>
                                <TextBlock Text="{Binding Path=NomeOperadora}" />
                            </StackPanel>
                            
                            <sdk:HierarchicalDataTemplate.ItemTemplate>
                                <!--TreeViewTipoGuia Template-->
                                <sdk:HierarchicalDataTemplate ItemsSource="{Binding ListaGuias}">
                                    <StackPanel>
                                        <TextBlock x:Name="txtTipoGuia" Text="{Binding Path=TipoGuia}" />
                                        <popup:PopupMenu RightClickElements="txtTipoGuia">
                                            <ListBox>
                                                <popup:PopupMenuItem Header="{Binding Path=TipoGuia,Converter={StaticResource TipoGuiaMenuConverter}}"
                                                                     Click="MenuTipoGuia_Click"/>
                                            </ListBox>
                                        </popup:PopupMenu>
                                    </StackPanel>
                                    <!--TreeViewNode Template-->
                                    <sdk:HierarchicalDataTemplate.ItemTemplate>

                                        <sdk:HierarchicalDataTemplate ItemsSource="{Binding ListaGuiaFaturamento}">
                                            <StackPanel>
                                                <TextBlock x:Name="txtNodeTreeView" Text="{Binding Path=Rotulo}" />
                                                <popup:PopupMenu RightClickElements="txtNodeTreeView" 
                                                                 IsEnabled="{Binding Path=Tipo,Converter={StaticResource treeViewNodeMenuConverter},ConverterParameter='Lote'}">
                                                    <ListBox>
                                                        <popup:PopupMenuItem Header="Criar Guia" Click="MenuCriaGuiaFaturamento_Click"/>
                                                        <popup:PopupMenuItem Header="Gerar XML" />
                                                    </ListBox>
                                                </popup:PopupMenu>
                                                <popup:PopupMenu RightClickElements="txtNodeTreeView"
                                                                 IsEnabled="{Binding Path=Tipo,Converter={StaticResource treeViewNodeMenuConverter},ConverterParameter='Solicitacao'}">
                                                    <ListBox>
                                                        <popup:PopupMenuItem Header="Abrir Guia" Click="MenuGuiaAbrir_Click" />
                                                        <popup:PopupMenuItem Header="Deletar Guia" />
                                                        <popup:PopupMenuItem Header="Gerar XML" />
                                                    </ListBox>
                                                </popup:PopupMenu>
                                            </StackPanel>
                                            
                                            <!--Lista Faturamento-->
                                            <sdk:HierarchicalDataTemplate.ItemTemplate>
                                                
                                                <sdk:HierarchicalDataTemplate>
                                                    <StackPanel>
                                                        <TextBlock x:Name="txtNodeTreeView" Text="{Binding Path=Rotulo}" />
                                                        <popup:PopupMenu RightClickElements="txtNodeTreeView">
                                                            <ListBox>
                                                                <popup:PopupMenuItem Header="Abrir Guia" Click="MenuGuiaAbrir_Click" />
                                                                <popup:PopupMenuItem Header="Deletar Guia" />
                                                            </ListBox>
                                                        </popup:PopupMenu>
                                                    </StackPanel>
                                                </sdk:HierarchicalDataTemplate>
                                                
                                            </sdk:HierarchicalDataTemplate.ItemTemplate>

                                        </sdk:HierarchicalDataTemplate>
                                        
                                    </sdk:HierarchicalDataTemplate.ItemTemplate>

                                </sdk:HierarchicalDataTemplate>

                            </sdk:HierarchicalDataTemplate.ItemTemplate>

                        </sdk:HierarchicalDataTemplate>
                    </sdk:TreeView.ItemTemplate>
                </sdk:TreeView>
            </toolkit:BusyIndicator>
            
            <Button x:Name="SalvarSessao_Button" Content="Autalizar Dados" Margin="0" Style="{StaticResource SalvarSessao_Button}" VerticalAlignment="Top" Height="22"
                    Click="ReloadTreeView_Click"/>
        </Grid>
        <sdk:GridSplitter HorizontalAlignment="Left" Width="5" Margin="0" Grid.Row="1" Background="#FFACDDDB" Grid.Column="1"/>
        <Grid x:Name="Topo" Margin="0" Grid.ColumnSpan="2" Background="#FF89BC33">
            <Rectangle x:Name="Header_Verde" Stretch="Fill" Grid.Row="0" Grid.Column="0" Margin="0" >
                <Rectangle.Effect>
                    <DropShadowEffect BlurRadius="30" Opacity="0.245"/>
                </Rectangle.Effect>
                <Rectangle.Fill>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <LinearGradientBrush.RelativeTransform>
                            <CompositeTransform CenterY="0.5" CenterX="0.5" Rotation="90"/>
                        </LinearGradientBrush.RelativeTransform>
                        <GradientStop Color="#FF7BAEAB"/>
                        <GradientStop Color="#FFACDDDB" Offset="1"/>
                    </LinearGradientBrush>
                </Rectangle.Fill>
            </Rectangle>
            <Rectangle x:Name="Header_Branco" Stretch="Fill" Grid.Row="0" Grid.Column="0" Margin="0" >
                <Rectangle.Fill>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <LinearGradientBrush.RelativeTransform>
                            <CompositeTransform CenterY="0.5" CenterX="0.5" Rotation="94"/>
                        </LinearGradientBrush.RelativeTransform>
                        <GradientStop Color="#FFEFF4F4" Offset="0.912"/>
                        <GradientStop Color="#00EFF4F4" Offset="0.565"/>
                    </LinearGradientBrush>
                </Rectangle.Fill>
            </Rectangle>
            <Image Margin="0,11,0,0" Source="/LiveTiss;component/Content/Aplicacao pequena.png" Stretch="Fill" HorizontalAlignment="Left" Height="73" Width="199" VerticalAlignment="Top"/>
            <Grid x:Name="Usuario" HorizontalAlignment="Right" Margin="0,10,14,10">
                <TextBlock x:Name="txtUserName" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="16" Height="19" HorizontalAlignment="Right"  Foreground="White" Margin="0" Text="Usuário"/>
                <Button x:Name="btnConfig" Content="configuração" Style="{StaticResource Botao_Topo}" Margin="0,0,32,0" FontSize="10.667" Height="26" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="90" Cursor="Hand" Click="btnConfig_Click"/>
                <Button x:Name="btnSair" Content="sair" Style="{StaticResource Botao_Topo}" Width="24" HorizontalAlignment="Right" FontSize="10.667" Height="26" VerticalAlignment="Bottom" Cursor="Hand" Click="btnSair_Click"/>
                <Rectangle x:Name="Linha_Divisao" Fill="White" HorizontalAlignment="Right" Height="18" Margin="0,0,26,8" VerticalAlignment="Bottom" Width="4" RenderTransformOrigin="0.5,0.5">
                    <Rectangle.RenderTransform>
                        <CompositeTransform ScaleY="0.8" ScaleX="0.4"/>
                    </Rectangle.RenderTransform>
                </Rectangle>
            </Grid>
        </Grid>
    </Grid>
</UserControl>
